from sqlalchemy.ext.asyncio import AsyncSession

from src.database import repositories as repo
from src.database.uow.base import SQLAlchemyBaseUoW


class SQLAlchemyUoW(SQLAlchemyBaseUoW):
    def __init__(
        self,
        *,
        session: AsyncSession,
        user_repo: repo.UserRepoImpl,
        user_reader: repo.UserReaderImpl,
        subscription_reader: repo.SubscriptionReaderImpl,
        subscription_repo: repo.SubscriptionRepoImpl,
        bot_settings_reader: repo.BotSettingsReaderImpl,
        activation_code_reader: repo.ActivationCodeReaderImpl,
        activation_code_repo: repo.ActivationCodeRepoImpl,
        category_reader: repo.CategoryReaderImpl,
        calendar_repo: repo.CalendarRepoImpl,
        calendar_reader: repo.CalendarReaderImpl,
        bill_reader: repo.BillReaderImpl,
        bill_repo: repo.BillRepoImpl,
    ) -> None:
        self.user_repo = user_repo
        self.user_reader = user_reader
        self.subscription_reader = subscription_reader
        self.subscription_repo = subscription_repo
        self.bot_settings_reader = bot_settings_reader
        self.activation_code_reader = activation_code_reader
        self.activation_code_repo = activation_code_repo
        self.category_reader = category_reader
        self.calendar_repo = calendar_repo
        self.calendar_reader = calendar_reader
        self.bill_reader = bill_reader
        self.bill_repo = bill_repo

        super().__init__(session=session)


def build_uow(session: AsyncSession):
    return SQLAlchemyUoW(
        session=session,
        user_repo=repo.UserRepoImpl(session),
        user_reader=repo.UserReaderImpl(session),
        subscription_reader=repo.SubscriptionReaderImpl(session),
        subscription_repo=repo.SubscriptionRepoImpl(session),
        bot_settings_reader=repo.BotSettingsReaderImpl(session),
        activation_code_reader=repo.ActivationCodeReaderImpl(session),
        activation_code_repo=repo.ActivationCodeRepoImpl(session),
        category_reader=repo.CategoryReaderImpl(session),
        calendar_repo=repo.CalendarRepoImpl(session),
        calendar_reader=repo.CalendarReaderImpl(session),
        bill_reader=repo.BillReaderImpl(session),
        bill_repo=repo.BillRepoImpl(session),
    )
